package com.dc.controller;

import com.dc.annotation.Log;
import com.dc.common.ResponseResultVO;
import com.dc.entity.ro.MaintenanceWorkOrderRO;
import com.dc.entity.vo.MaintenanceVO;
import com.dc.service.MaintenanceWorkOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

@Api(tags = "维保工单管理")
@RestController
@RequestMapping("/maintenanceWorkOrder")
public class MaintenanceWorkOrderController {

    @Resource
    private MaintenanceWorkOrderService maintenanceWorkOrderService;

    @Log(title = "维保工单管理", businessDesc = "增加")
    @ApiOperation(value = "增加", notes = "增加")
    @PostMapping("/insertMaintenanceWorkOrder")
    public ResponseResultVO insertMaintenanceWorkOrder(@RequestBody MaintenanceWorkOrderRO ro) {
        return maintenanceWorkOrderService.insertMaintenanceWorkOrder(ro);
    }


    @Log(title = "维保工单管理", businessDesc = "修改")
    @ApiOperation(value = "修改", notes = "修改")
    @PostMapping("/updateMaintenanceWorkOrder")
    public ResponseResultVO updateMaintenanceWorkOrder(@RequestBody MaintenanceWorkOrderRO ro) {
        return maintenanceWorkOrderService.updateMaintenanceWorkOrder(ro);
    }


    @Log(title = "维保工单管理", businessDesc = "删除")
    @ApiOperation(value = "删除", notes = "删除")
    @GetMapping("/deleteMaintenanceWorkOrder")
    public ResponseResultVO deleteMaintenanceWorkOrder(@RequestParam String id) {
        return maintenanceWorkOrderService.deleteMaintenanceWorkOrder(id);
    }

    @ApiOperation(value = "查询列表", notes = "查询列表")
    @PostMapping("/selectMaintenanceWorkOrderList")
    public ResponseResultVO<MaintenanceVO> selectMaintenanceWorkOrderList(@RequestBody MaintenanceWorkOrderRO ro) {
        return maintenanceWorkOrderService.selectMaintenanceWorkOrderList(ro);
    }

    @ApiOperation(value = "列表导出", notes = "列表导出")
    @PostMapping("/maintenanceWorkOrderExport")
    public void maintenanceWorkOrderExport(HttpServletResponse response, @RequestBody MaintenanceWorkOrderRO ro) {
        maintenanceWorkOrderService.maintenanceWorkOrderExport(response, ro);
    }
}
